﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ADO.NET.Samples.Common;
using System.Data.Objects;

namespace ADO.NET.Samples.Forms.EntityFramework
{
    [FormDescription("Entity SQL", "Entity SQL example.")]
    public partial class EntitySQL : Form
    {
        public EntitySQL()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Data binding
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EntitySQL_Load(object sender, EventArgs e)
        {
            DBEntities db = new DBEntities();
           
            string selectCommand = "SELECT VALUE User from Users as User order by User.UserID DESC";
            ObjectQuery<User> users = new ObjectQuery<User>(selectCommand, db, MergeOption.NoTracking);
            this.dataGridView1.DataSource = users.AsEnumerable();
        }
    }
}
